package cn.myjerry.io.buffered;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

/**
 * 字符缓冲流 + 新增方法(不能发生多态)
 * @author Jerry
 *
 */
public class BufferedCharDemo {
	public static void main(String[] args) {
		
	}
	public static void copyFile(String srcPath, String destPath) throws IOException {
		File src = new File(srcPath);
		File dest = new File(destPath);
		BufferedReader reader = null;
		BufferedWriter writer = null;
		reader = new BufferedReader(new FileReader(src));
		writer = new BufferedWriter(new FileWriter(dest, true));
		/*char[] car = new char[1024];
		int len = 0;
		while(-1 != (len = reader.read(car))) {
			writer.write(car, 0, len);
			writer.flush();
		}*/
		String line = null;
		while(null != (line = reader.readLine())) {
			writer.write(line);
			writer.newLine();
		}
		reader.close();
		writer.close();
	}
}
